<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="description" content="">
    <meta name="author" content="">    
	<meta name="keywords" content="玩精灵,财经智库">	
	<title>玩精灵后台-登录</title>	
	<link rel="shortcut icon" href="favicon.ico" />	
	<link rel="stylesheet" type="text/css" href="css/lqcss.css">
	<link rel="stylesheet" type="text/css" href="css/lqpublic.css">
	<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
	<script type="text/javascript" src="js/lqjs.js"></script>
	<script type="text/javascript" src="js/jquerysession.js"></script>
	<!--[if (gte IE 6)&(lte IE 10)]>
	  <link href="css/lqcssie.css" rel="stylesheet" type="text/css">
	  <link href="css/lqpublicie.css" rel="stylesheet" type="text/css">
	<![endif]-->
</head>

	<body>
		<div class="container">
		<!-- 主体部分 -->
			<div class="containermain">
				<!-- 头部 -->
				<div id="header">
					<div class="header">
						<div class="logo">
							<img class="logoimg" src="images/icologo@3x.png" alt="玩精灵">
							<h2 class="logotext">玩精灵</h2>
						</div>
						<!-- <h2 class="biaoyu">欢迎登录后台管理系统</h2> -->
						<!-- <div class="userdiv">
							<div class="userde">
								<img class="userimg" src="images/icologo@3x.png" />
								<span class="username">Admin</span>
								<i class="icoup"></i>
							</div>
							账户信息
							<div id="userdetils">
								<p class="usertext"><i class="userico"></i>账户:18989876567</p>
								<a class="userbtn originbtn">退出登录</a>
							</div>
						</div> -->
					</div>
				</div>

				<!-- 内容 -->
				<div id="mainall">
					<img class="loginbg" src="images/loginbg.jpg" alt="" />
					<!-- 登录 -->
					<div class="logindiv">
						<h2 class="login_title">欢迎登录玩精灵后台管理系统</h2>
						<div class="login_de">
							<div class="login_p"><input id="username" class="login_inp" type="text" name=""  placeholder="用户名"></div>
							<div class="login_p"><input id="userpassword" class="login_inp" type="password" name=""  placeholder="登录密码"></div>
						</div>
						<input type="submit" class="login_btn originbtn" value="登录" onclick="logins()"/>
						
					</div>
				</div>
			</div>
			
		</div>
<script type="text/javascript">
	$("#username").focus(function(){
		$(".usertype").hide(300);
	})

	// 登录
	function logins(){
		console.log('登录');
		// var usertypeinp = $("#usertypeinp").val();
		var username = $("#username").val();
		var userpassword = $("#userpassword").val();
		// 验证为空
		if(username.length!=0 && userpassword.length!=0){	
		$.ajax({
		type: "post",
		url: url+"account/login",		
		data:{
			'name': username,
			'password': userpassword,
		},
		success: function(data){
			console.log(data);			
			var yonhu = data.data;
			console.log(yonhu);
			if (data.code == '2000') {
				console.log('登录');
				var creattime = timeStamp2String(yonhu[0].createdDatetime);
				$.session.set('creattime',creattime);//创建时间
				$.session.set('loginName',yonhu[0].name);//用户名
				// $.session.set('password',yonhu.password);//密码
				// $.session.set('rank',yonhu.rank);//用户类别
				// console.log($.session.get('rank'));
				$.session.set('sid',yonhu[0].sid);//用户类别
				$.session.set('token',yonhu[0].token);//token,用户识别 
				console.log(yonhu[0].name);	
				console.log($.session.get('loginName'));	
				window.location.href = "index.html";
				}else if(data.code == '5000'){
					console.log('账号或者密码错误');
					alert("账号或者密码错误");
				}else{
					alert("系统错误");
				}
			}
		})
		}else{
			// if(orank==0){
			// 	alert("请选择登录类型");
			// 	return false;
			// }
			if(username.length==0 ){
				alert("请输入用户名");
				return false;
			}
			if(userpassword.length==0 ){
				alert("请输入密码");
				return false;
			}
		}
		return false;
	}

/*直接点击enter免除手动点击登录按钮*/    
$(document).keyup(function(event){

if(event.keyCode ==13){
logins();    
}

});
	
// }
</script>
	</body>
	</html>